<?php
class AML_Model_Admins
{
	protected $_name= "admin";
	//$this->_name = DB_PREFIX.$this->_name;
	function checkUnique($username, $id)
	{
		$select =  $this->_db->select('admin_username')->from($this->_name)->where('admin_username="'.$username.'" AND admin_id<>"'.$id.'"');
		$result = $this->getAdapter()->fetchOne($select);
		if($result){
			return true;
		}
		return false;
	}
	
	function checkUniqueemail($email, $id)
	{
		
		$select =  $this->_db->select('admin_email')->from($this->_name)->where('admin_email="'.$email.'" AND admin_id<>"'.$id.'"');						
		$result = $this->getAdapter()->fetchAll($select);
		
		if($result){
			return true;
		}
		return false;
	}
	
	function optionAdminList($selid) 
	{	
		$select =  $this->_db->select()->from($this->_name)->where("admin_id<>1 AND admin_status=1");						
		$result = $this->getAdapter()->fetchAll($select);
		$list = '<option value="" >Click to Assign</option>\n';
		foreach ($result as $key => $val): 
			if($val['admin_id'] == $selid) $sl = 'selected="selected"'; else $sl = '';		
			$list .= '<option value="'.$val['admin_id'].'" '.$sl.'>'. $val['admin_firstname'].' '.$val['admin_lastname'].'</option>\n';		
		endforeach; 
		return $list; 
	} # status List 
	
	public function getAdminName($reg_id){		
		$select = $this->_db->select()
							->from($this->_name)
							->where('admin_id=?',$reg_id);
		$result = $this->getAdapter()->fetchRow($select);
		return $result['admin_firstname']." ".$result['admin_lastname'];	
	
	}
}
